package com.ruoyi.system.userController;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.FhUser;
import com.ruoyi.system.service.IFhUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 用户控制Controller
 * 
 * @author oy
 * @date 2024-11-07
 */
//@Api("用户控制")
@RestController
@RequestMapping("/system/userFhUser")
public class UserFhUserController extends BaseController
{
    @Autowired
    private IFhUserService fhUserService;

    /**
     * 查询用户控制列表
     */
    @Anonymous

//    @ApiOperation("查询用户控制列表")
    @GetMapping("/list")
    public TableDataInfo list(FhUser fhUser)
    {
        startPage();
        List<FhUser> list = fhUserService.selectFhUserList(fhUser);
        return getDataTable(list);
    }

    /**
     * 导出用户控制列表
     */
    @Anonymous
//    @ApiOperation("导出用户控制列表")
    @Log(title = "用户控制", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FhUser fhUser)
    {
        List<FhUser> list = fhUserService.selectFhUserList(fhUser);
        ExcelUtil<FhUser> util = new ExcelUtil<FhUser>(FhUser.class);
        util.exportExcel(response, list, "用户控制数据");
    }

    /**
     * 获取用户控制详细信息
     */
    @Anonymous
//    @ApiOperation("获取用户控制详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fhUserService.selectFhUserById(id));
    }

    /**
     * 新增用户控制
     */
    @Anonymous
//    @ApiOperation("新增用户控制")
    @Log(title = "用户控制", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FhUser fhUser)
    {
        return toAjax(fhUserService.insertFhUser(fhUser));
    }

    /**
     * 修改用户控制
     */
    @Anonymous
//    @ApiOperation("修改用户控制")
    @Log(title = "用户控制", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FhUser fhUser)
    {
        return toAjax(fhUserService.updateFhUser(fhUser));
    }

    /**
     * 删除用户控制
     */
    @Anonymous
//    @ApiOperation("删除用户控制")
    @Log(title = "用户控制", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fhUserService.deleteFhUserByIds(ids));
    }
}
